﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DBMigrator.Core.DbObjects.Data.Select;
using DBMigrator.Core.DbObjects.Data.What;
using DBMigrator.Core.DbObjects.Data.Where;
using Rhino.Mocks;
using Xunit;

namespace DBMigrator.Core.Tests.DbObjects.Data
{
    public class BaseSelectTests
    {
        private readonly IFrom from;
        private readonly IWhere where;

        public BaseSelectTests()
        {
            from = MockRepository.GenerateMock<IFrom>();
            where = MockRepository.GenerateMock<IWhere>();
        }

        [Fact]
        public void ConstructorShouldThrowIfFromIsNull()
        {
            Assert.Throws<ArgumentNullException>(() => new BaseSelectImplementation(null, where));
        }

        [Fact]
        public void ConstructorShouldSetFrom()
        {
            Assert.Equal(from, new BaseSelectImplementation(from, where).From);
        }

        [Fact]
        public void ConstructorShouldThrowIfWhereIsNull()
        {
            Assert.Throws<ArgumentNullException>(() => new BaseSelectImplementation(from, null));
        }

        [Fact]
        public void ConstructorShouldSetWhere()
        {
            Assert.Equal(where, new BaseSelectImplementation(from, where).Where);
        }

        private class BaseSelectImplementation : BaseSelect
        {
            public override Type SqlGenerationType
            {
                get { throw new NotImplementedException(); }
            }

            public BaseSelectImplementation(IFrom from, IWhere where)
                : base(from, where)
            {}
        }
    }
}
